// pages/Wtjcxq/Wtjcxq.js
import ajax from '../../utils/api.js';
import dateChangeObj from '../../utils/util.js';
Page({

    /**
     * 页面的初始数据
     */
    data: {
        jianceshuObj:{},
        dateChange:{},
        dateChange:[],
        ziliao:[],
        rwtongzhi:{},
        rwshoulishu:[],
        shoulis:{},
        page:1,
        pageSize:10,
        // number:10,
        daohang: [
            {name: "委托检测书"},
            {name: "委托检测资料"},
            {name: "设备反馈问题"},
            {name: "任务通知单"},
            {name: "任务受理书"},
            {name: "检测快报"},
            // {name: "委托时间变更"},
          ],
        
        wtjcList:[{
            name:'T-2020070144-D-02',
            ckbg:'查看报告',
            times:'2022-04-11',
            babh:'闽DC-S18762',
            jcjl:'合格',
            tjzt:'审核通过'
            },],
        bgrqList:[{
            name:'T-2020070144-D-02',
            times:'2022-04-11',
            sbmc:'施工升降机',
            names:'厦门SM商业城（三期）',
            jclb:'2022-04-15',
            shzt:'未提交'
        },{
            name:'T-2020070144-D-02',
            times:'2022-04-11',
            sbmc:'施工升降机',
            names:'厦门SM商业城（三期）',
            jclb:'2022-04-15',
            shzt:'未提交'
        }],
          currentActive:0,
          hiddenName:false,
          date: '',
          detailId:'',
          
        },
        switchNav: function (e){
            var cur = e.currentTarget.dataset.current;                
            this.setData({
                currentActive: cur,
            })      
            if (cur == 5){
                console.log('66666666666')
                this.jicekbliebao()
            }else if(cur == 0){
                this.jiancekuaibao()
            }else if(cur == 1){
                this.jiancezl()
            }else if(cur == 3){
              this. rwtzList()
            }
            console.log('ccccc',this.data.currentActive)
        },
        shghnn:function(){
            this.setData({
                hiddenName:!this.data.hiddenName
            })
        },
        bindDateChange: function(e) {
            console.log('picker发送选择改变，携带值为', e.detail.value)
            this.setData({
              date: e.detail.value
            })
          },
          bindDateChange2: function(e) {
            console.log('picker发送选择改变，携带值为', e.detail.value)
            this.setData({
              date2: e.detail.value
            })
        },
        goto_Kblb2xq(){
            wx.navigateTo({
              url: '/pages/Kblb2xq/Kblb2xq',
            })
        },
        jiancekuaibao(){ //获取委托检测书接口
            var _this=this
            ajax.jiancekb(this.data.detailId).then((res)=>{
                    _this.setData({
                        jianceshuObj:res.data,
                        dateChange: _this.data.dateChange,
                        dateDetail:dateChangeObj.formatTimeTwo(res.data.reqDate,'Y-M-D')
                      })    
                } ).catch((err) => {
                    console.log(err)
                  });  
       },
       jiancezl(){ //获取检测资料接口
        var _this=this
        ajax.jiancezliao(this.data.detailId).then((res)=>{
              
                _this.setData({
                    ziliao:res.data, 
                  })    
            } ).catch((err) => {
                console.log(err)
              });  
   },
   rwtzList(){ //获取任务通知单
    var _this=this
    ajax.rwtzd(this.data.detailId).then((res)=>{
            _this.setData({
                rwtongzhi:res.data, 
                datas: _this.data.datas,
                datas2: _this.data.datas2,
                datas:dateChangeObj.formatTimeTwo(res.data.noticeDate,'Y-M-D'),
                datas2:dateChangeObj.formatTimeTwo(res.data.reqDate,'Y-M-D')
              })    
        } ).catch((err) => {
            console.log(err)
          });  
},
jicekbliebao(){ //获取检测快报列表
    var _this=this
    console.log('23322222')
    ajax.jckb( {
        page: _this.data.page,//分页页码，数字类型
        pageSize: _this.data.pageSize,//每页条数
        number: _this.data.number,
    }).then((res)=>{
        console.log('12313212131313')
            _this.setData({
                rwshoulishu:res.data.content, 
              })    
        } ).catch((err) => {
            console.log(err)
          });  
},
jicekbList(){ //获取任务受理书
    var _this=this
    ajax.rwsls(this.data.detailId).then((res)=>{
            _this.setData({
                shoulis:res.data, 
              })    
        } ).catch((err) => {
            console.log(err)
          });  
},
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        if (options.id != ''){
            this.setData({
                detailId:options.id,
            })
            this.setData({
                number:options.number
            })
            // console.log('23333333333333333333333333',this.data.number,this.data.detailId)
            this.jiancekuaibao()
            this.jiancezl()
            // this.jicekbList()
        }
        
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
        // this.jiancekuaibao()
        // this.jiancezl()
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})